// TextProperty.cpp: implementation of the TextProperty class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "phsshare.h"
#include "TextProperty.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

TextProperty::TextProperty()
{
	m_bReversal = FALSE;
	m_bReverse = FALSE;
	m_bVertical = FALSE;
	m_dbHeight = 0.0;
	m_dbAngleOfRotation = 0.0;
	m_dbWidthRatio = 0.0;
	m_nAlignStyle = 0;
	
}

TextProperty::~TextProperty()
{
	
}

BOOL TextProperty::InitSetting()
{
	if(m_strTextContentName.IsEmpty())
		return FALSE;

	m_strTextStyleName = PHSRegEdit().GetRegKey(_T("Settings"), m_strTextContentName + _T("-STYLENAME"), CString(_T("")));
	m_strFont = PHSRegEdit().GetRegKey(_T("Settings"), m_strTextContentName + _T("-SHXFILENAME"), CString(_T("")));
	m_strBigFont = PHSRegEdit().GetRegKey(_T("Settings"), m_strTextContentName + _T("-BIGFILENAME"), CString(_T("")));
	m_dbHeight = PHSRegEdit().GetRegKey(_T("Settings"), m_strTextContentName + _T("-HEIGHT"), 0.0f);
	m_dbWidthRatio = PHSRegEdit().GetRegKey(_T("Settings"), m_strTextContentName + _T("-WIDTH"), 0.0f);
	m_dbAngleOfRotation = PHSRegEdit().GetRegKey(_T("Settings"), m_strTextContentName + _T("-OBLIQUEANGLE"), 0.0f);
	m_bReversal = PHSRegEdit().GetRegKey(_T("Settings"), m_strTextContentName + _T("-BLUP2DOWN"), 0);
	m_bReverse = PHSRegEdit().GetRegKey(_T("Settings"), m_strTextContentName + _T("-BLBACKWARD"), 0);
	m_bVertical = PHSRegEdit().GetRegKey(_T("Settings"), m_strTextContentName + _T("-BLVERTICAL"), 0);
	m_nAlignStyle = PHSRegEdit().GetRegKey(_T("Settings"), m_strTextContentName + _T("-ALIGN"), 0);

	return TRUE;
}


void TextProperty::SetTextStyle(TextStyle& Style)
{
	m_bReversal = Style.IsReversal();
	m_bReverse = Style.IsReverse();
	m_bVertical = Style.IsVertical();
	m_dbAngleOfRotation = Style.GetAngleOfRotation();
	m_dbHeight = Style.GetHeight();
	m_dbWidthRatio = Style.GetWidthRatio();
	m_strBigFont = Style.GetBigFont();
	m_strFont = Style.GetFont();
	m_strTextStyleName = Style.GetStyleName();
	m_nAlignStyle = Style.GetAlignStyle();
}

BOOL TextProperty::SaveSetting()
{
	
    PHSRegEdit().SetRegValue(_T("Settings"), m_strTextContentName + _T("-STYLENAME"), m_strTextStyleName);
    PHSRegEdit().SetRegValue(_T("Settings"), m_strTextContentName + _T("-SHXFILENAME"), m_strFont);
    PHSRegEdit().SetRegValue(_T("Settings"), m_strTextContentName + _T("-BIGFILENAME"), m_strBigFont);
	PHSRegEdit().SetRegValue(_T("Settings"), m_strTextContentName + _T("-HEIGHT"), m_dbHeight);
    PHSRegEdit().SetRegValue(_T("Settings"), m_strTextContentName + _T("-WIDTH"), m_dbWidthRatio);
    PHSRegEdit().SetRegValue(_T("Settings"), m_strTextContentName + _T("-OBLIQUEANGLE"), m_dbAngleOfRotation);
    PHSRegEdit().SetRegValue(_T("Settings"), m_strTextContentName + _T("-BLUP2DOWN"), m_bReversal);
    PHSRegEdit().SetRegValue(_T("Settings"), m_strTextContentName + _T("-BLBACKWARD"), m_bReverse);
    PHSRegEdit().SetRegValue(_T("Settings"), m_strTextContentName + _T("-BLVERTICAL"), m_bVertical);
    PHSRegEdit().SetRegValue(_T("Settings"), m_strTextContentName + _T("-ALIGN"), m_nAlignStyle);

	return TRUE;
}

CString TextProperty::GetTextContentName()
{
	return m_strTextContentName;
}

void TextProperty::SetTextContentName(const CString& strName)
{
	m_strTextContentName = strName;
	m_strTextContentName.TrimLeft();
	m_strTextContentName.TrimRight();
}

BOOL TextProperty::IsReversal()
{
	return m_bReversal;
}

void TextProperty::SetReversal(BOOL bReversal)
{
	m_bReversal = bReversal;
}

BOOL TextProperty::IsReverse()
{
	return m_bReverse;
}

void TextProperty::SetReverse(BOOL bReverse)
{
	m_bReverse = bReverse;
}

BOOL TextProperty::IsVertical()
{
	return m_bVertical;
}

void TextProperty::SetVertical(BOOL bVertical)
{
	m_bVertical = bVertical;
}

DOUBLE TextProperty::GetHeight()
{
	return m_dbHeight;
}

void TextProperty::SetHeight(DOUBLE dbHeight)
{
	m_dbHeight = dbHeight;
}

DOUBLE TextProperty::GetAngleOfRotation()
{
	return m_dbAngleOfRotation;
}

void TextProperty::SetAngleOfRotation(DOUBLE dbAngle)
{
	m_dbAngleOfRotation = dbAngle;
}

DOUBLE TextProperty::GetWidthRatio()
{
	return m_dbWidthRatio;
}

void TextProperty::SetWidthRatio(DOUBLE dbRatio)
{
	m_dbWidthRatio = dbRatio;
}

CString TextProperty::GetFont()
{
	return m_strFont;
}

void TextProperty::SetFont(const CString& strFont)
{
	m_strFont = strFont;
}

CString TextProperty::GetBigFont()
{
	return m_strBigFont;
}

void TextProperty::SetBigFont(const CString& strFont)
{
	m_strBigFont = strFont;
}

INT TextProperty::GetAlignStyle()
{
	return m_nAlignStyle;
}

void TextProperty::SetAlignstyle(INT nStyle)
{
	m_nAlignStyle = nStyle;
}

CString TextProperty::GetTextStyleName()
{
	return m_strTextStyleName;
}

void TextProperty::SetTextStyleName(const CString& strName)
{
	m_strTextStyleName = strName;
}
